import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'
Vue.use(Vuex)

const state = {
  access: false,
  cert: {},
  login: {},
  web_ui: false,
  time: '',
  lang: 'zh'
}
const mutations = {
  // ADD_NOTE (state) {
  //   const newNote = {
  //     text: 'New note',
  //     favorite: false
  //   }
  //   state.notes.push(newNote)
  //   state.activeNote = newNote
  // },

  EDIT_LOGIN (state, payload) {
    state.login = payload
  },
  EDIT_WEB (state, payload) {
    state.web_ui = payload
  },
  EDIT_Access (state, payload) {
    state.access = payload
  },
  EDIT_Time (state, payload) {
    state.time = payload
  },
  // DELETE_NOTE (state) {
  //   state.notes.$remove(state.activeNote)
  //   state.activeNote = state.notes[0]
  // },

  // TOGGLE_FAVORITE (state) {
  //   state.activeNote.favorite = !state.activeNote.favorite
  // },

  // SET_ACTIVE_NOTE (state, note) {
  //   state.activeNote = note
  // }
}
const store = new Vuex.Store({
  state,
  mutations,
  plugins: [createPersistedState({ storage: window.sessionStorage })]
})

export default store
